<div class="Item hr">
    <div class="current">模板风格列表</div>
</div>
<form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td>模板缩略图</td>
                <td>模板信息</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="list" id="tpl" empty="$empty">
            <tr align="center">
                <td width="150"><img src="{$tpl['litpic']|substr=###,1}" width="120" class="img-thumbnail" /></td>
                <td style="text-align:left;">
                	<p>模板名称：{$tpl.name}</p>
                	<p>模板作者：{$tpl.author}</p>
                	<p>发布时间：{$tpl.pubdate}</p>
                	<p>模板简介：{$tpl.description}</p>
                </td>
                <td width="100">
                <eq name='tpl[isdefault]' value='1'>[ <a href="javascript:;" style="color:#CCC;">默认模板</a> ]<else />[ <a href="javascript:;" data-url='{:U("setDefault")}' class="setTheme" data-theme='{$tpl.tplname}' data-name="{$tpl.name}">设为默认模板</a> ]</eq>
                </td>
            </tr>
            </volist>
        </tbody>
    </table>
</form>

<script type="text/javascript">
$(function(){
    $(".setTheme").click(function(){
        var url = $(this).data("url");
        var name = $(this).data("name");
        var theme = $(this).data("theme");

        popup.confirm("您确定设置 <b>" + name + "</b> 为默认模板？", '温馨提示',function(action){
            if(action == 'ok'){
                $.ajax({
					'url' : url,
					'dataType' : 'JSON',
					'type' : 'POST',
					'data' : {'theme' : theme},
					'success' : function(json){
						if (json.status) {
							popup.success(json.info, '设置成功', function(){
								if(json.url){
									window.location.href = json.url;
								}else{
									top.window.location.reload();
								}
							});
							setTimeout(function(){
								popup.close("asyncbox_success");
							},2000);
		
							setTimeout(function(){
								top.window.location.reload();
							},3000);
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
				});
            }
        });

        return false;
    });
});
</script>
